package org.jash.shopdemo2212;

import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

public class MainActivity extends AppCompatActivity {
    private TextView tv;
    private Handler handler = new Handler(Looper.getMainLooper());
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        tv = findViewById(R.id.tv);
        for (int i = 0; i < 5; i++) {
            String s = "倒计时" + (5 - i) + "s";
            handler.postDelayed(() -> tv.setText(s), i * 1000);
        }
        handler.postDelayed(() -> {
            startActivity(new Intent(this, LoginActivity.class));
            finish();
        }, 5000);
        tv.setOnClickListener(v -> {
            startActivity(new Intent(this, LoginActivity.class));
            finish();
            handler.removeCallbacksAndMessages(null);
        });
    }
}